home *** CD-ROM | disk | FTP | other *** search
/ 100 Plus Great Games 2 / 100PLUSV2.BIN / games / Darts(Scram).dxr / Internal_2_throw darts.ls < prev    next >
Encoding:
Text File  |  2002-01-25  |  5.2 KB  |  184 lines

  1. property spriteNum, pDart, pLoc, pDistanceFromBoard, pBoardHeightFromGround, pPower, pDeterMinePower, pGravity, pair, pDiffer, pScale, pHeightOfDart, pOgHeight, pOgWidth, pFollow, hateV, hateH, myOloc, myOh, myOv, myOr
  2. global gDartCount, gEnableGrab, gEnablethrow, gIB, gBscreen, gDartPoint, gTargets, gRound, gCRBox, gDartButtons, gCurrentScore, gRoundScore, gCSBox, gRSBox, gDartScore, gTargetsBlocked, gDartList, gCompDart
  3.  
  4. on beginSprite me
  5.   gDartList.add(spriteNum)
  6.   myOloc = sprite(spriteNum).loc
  7.   myOh = sprite(spriteNum).height
  8.   myOv = sprite(spriteNum).width
  9.   myOr = sprite(spriteNum).rotation
  10. end
  11.  
  12. on cleanUp me
  13.   sprite(spriteNum).loc = myOloc
  14.   sprite(spriteNum).height = myOh
  15.   sprite(spriteNum).width = myOv
  16.   sprite(spriteNum).rotation = myOr
  17. end
  18.  
  19. on init me
  20.   pDart = sprite(spriteNum)
  21.   pDistanceFromBoard = 96
  22.   pBoardHeightFromGround = 68
  23.   pGravity = 0.59999999999999998
  24.   pHeightOfDart = 28
  25.   pOgHeight = pDart.height
  26.   pOgWidth = pDart.width
  27.   pFollow = timeout("follow").new(1, #followMouse, me)
  28.   pair = VOID
  29. end
  30.  
  31. on followMouse me
  32.   if (the mouseH >= 0) and (the mouseH <= (the stage).rect.width) and ((the mouseV >= 250) and (the mouseV <= (the stage).rect.height)) then
  33.     pDart.loc = the mouseLoc
  34.   else
  35.     pDart.locH = the mouseH
  36.   end if
  37. end
  38.  
  39. on mouseDown me
  40.   if voidp(pair) and (pDistanceFromBoard > 0) then
  41.     gEnablethrow = 1
  42.     pFollow.forget()
  43.     pLoc = []
  44.     pLoc[1] = pDart.locH
  45.     pLoc[2] = pDart.locV
  46.     pDistanceFromBoard = 96
  47.     pHeightOfDart = 28
  48.     pDeterMinePower = timeout("power" & string(spriteNum)).new(5, #buildPower, me)
  49.   end if
  50. end
  51.  
  52. on mouseUp me
  53.   if gEnablethrow and (pDistanceFromBoard > 0) then
  54.     puppetSound(4, member("throw dart"))
  55.     gEnablethrow = 0
  56.     hateH = the mouseH
  57.     hateV = the mouseV
  58.     pDartsCount = pDartsCount + 1
  59.     pDeterMinePower.forget()
  60.     buildPower()
  61.     pair = timeout("pAir" & string(spriteNum)).new(5, #thrown, me)
  62.   end if
  63. end
  64.  
  65. on mouseUpOutSide me
  66.   if gEnablethrow and (pDistanceFromBoard > 0) then
  67.     puppetSound(4, member("throw dart"))
  68.     gEnablethrow = 0
  69.     hateH = the mouseH
  70.     hateV = the mouseV
  71.     pDartsCount = pDartsCount + 1
  72.     pDeterMinePower.forget()
  73.     buildPower()
  74.     pair = timeout("pAir" & string(spriteNum)).new(10, #thrown, me)
  75.   end if
  76. end
  77.  
  78. on buildPower me
  79.   pPower = -((float(hateV) - pLoc[2]) * 0.17999999999999999) * 0.72999999999999998
  80.   pDiffer = -((float(hateH) - pLoc[1]) * 0.17999999999999999) * 0.72999999999999998
  81.   if pPower < 10 then
  82.     pPower = 10
  83.   end if
  84.   if pPower > 22 then
  85.     pPower = 22
  86.   end if
  87. end
  88.  
  89. on thrown me
  90.   pDart.height = pDart.height - 3.54000000000000004
  91.   pDart.width = pDart.width - 3.54000000000000004
  92.   pDart.rotation = pDart.rotation + (pPower * 1.30000000000000004)
  93.   pPower = pPower - pGravity
  94.   pDistanceFromBoard = float(pDistanceFromBoard) - 2.5
  95.   pHeightOfDart = pHeightOfDart + pPower
  96.   pLoc[2] = pLoc[2] - pPower
  97.   pLoc[1] = pLoc[1] - pDiffer
  98.   pDart.locV = pLoc[2]
  99.   pDart.locH = pLoc[1]
  100.   pLoc[2] = pDart.locV
  101.   pLoc[1] = pDart.locH
  102.   if pDistanceFromBoard <= 0 then
  103.     if pDart.locV < 440 then
  104.       og = [290.0, 220.0]
  105.       pd = [pDart.locH.float, pDart.locV.float]
  106.       vec = [pd[1] - og[1], pd[2] - og[2]]
  107.       veclen = sqrt((vec[1] * vec[1]) + (vec[2] * vec[2]))
  108.       if veclen > 190 then
  109.         puppetSound(4, member("dart hit"))
  110.       else
  111.         puppetSound(4, member("dart hit 2"))
  112.       end if
  113.     else
  114.       puppetSound(4, member("hit floor"))
  115.     end if
  116.     pair.forget()
  117.     gDartPoint.loc = pDart.loc
  118.     repeat with i = 1 to gTargets.count
  119.       updateStage()
  120.       if gDartPoint.intersects(gTargets[i]) then
  121.         gCurrentScore = gCurrentScore + sprite(gTargets[i]).returnPoints()
  122.         gCSBox.text = string(gCurrentScore)
  123.         gDartScore[gDartCount] = string(sprite(gTargets[i]).returnPoints())
  124.       end if
  125.     end repeat
  126.     member("dart" && string(gDartCount)).text = string(gDartScore[gDartCount])
  127.     gEnableGrab = 1
  128.     if gDartCount = 3 then
  129.       gBscreen = timeout("bscreen").new(800, #bscreen, me)
  130.     end if
  131.   end if
  132. end
  133.  
  134. on bscreen me
  135.   gBscreen.forget()
  136.   whoDart = 1
  137.   repeat with i = 1 to 3
  138.     the randomSeed = the ticks
  139.     if gTargets.count > 0 then
  140.       hate = 1
  141.       repeat while hate
  142.         hi = gTargets[random(gTargets.count)]
  143.         if not gTargetsBlocked.findPos(hi) then
  144.           hate = 0
  145.           puppetSound(6, member("throw dart"))
  146.           gCompDart[whoDart].throw(hi)
  147.           whoDart = whoDart + 1
  148.           gTargetsBlocked.add(hi)
  149.           sprite(hi).blend = 50
  150.           sprite(hi).color = rgb(0, 200, 100)
  151.           gTargets.deleteOne(hi)
  152.           updateStage()
  153.         end if
  154.       end repeat
  155.     end if
  156.   end repeat
  157.   repeat with u = 1 to gCompDart.count
  158.     gCompDart[u].cleanUp()
  159.   end repeat
  160.   gDartCount = 0
  161.   gRound = gRound + 1
  162.   gDartScore = [0, 0, 0]
  163.   gCRBox.text = string(gRound)
  164.   repeat with i = 1 to 3
  165.     member("dart" && string(i)).text = "0"
  166.   end repeat
  167.   repeat with i = 1 to gDartList.count
  168.     sprite(gDartList[i]).cleanUp()
  169.   end repeat
  170.   repeat with i = 1 to gDartButtons.count
  171.     sprite(gDartButtons[i]).visible = 1
  172.   end repeat
  173.   repeat with i = 1 to gIB.count
  174.     sprite(gIB[i]).cleanUp()
  175.   end repeat
  176.   if gTargets.count = 0 then
  177.     gameEnd()
  178.   end if
  179. end
  180.  
  181. on gameEnd me
  182.   go("game over")
  183. end
  184.